<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
   <title>注册</title>
   <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
   <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
   <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
  <style>
	.table th{
		text-align:center;
	}
	.table td{
		text-align:center;
	}
	#left{
		width:20%;
		float:left;
	}
	#content{
		width:80%;
		margin-left:20%;
	}
	#info{
		font-size:20px;
	}
	 #pageButton{
			width:80%;
			margin-left:10%;
	   }
	   #right{
			margin-left:50%;
			
	   }
  </style>
</head>
<?php 	require_once("declogin.php");  ?>
<body>
	<nav class="navbar navbar-inverse" role="navigation">
   <div class="navbar-header">
      <a class="navbar-brand" id="info">FishVideo 信息管理平台</a>
   </div>
		
    <ul class="nav navbar-nav navbar-right">
	<li><a>欢迎你<?php  echo $_SESSION['adminname'];?>&nbsp&nbsp&nbsp&nbsp</a></li>
     </ul>
	  
</nav>
	<div class="container" id=left>
	<?php
	require_once("menu.html");  
	?>
	</div>
		<?php
		   require_once("../utils/upload.php");
		   require_once("../utils/db.php");
		   $conn=connect();
		   $realpath="../video/upload/";
			if(isset($_POST['changeVideo'])){//如果执行修改
				$sql="update fishvideo_video set yjl_videoname='{$_POST['videoname']}',
				yjl_tid='{$_POST['tid']}',yjl_intro='{$_POST['intro']}',
				yjl_lintro='{$_POST['lintro']}'";
				if(isset($_FILES['pic']) && $_FILES['pic']['size']!=0){//如果更换缩略图
					$pic_path=GetPic("pic",$realpath,"0");
					$sql.=",yjl_pic='{$pic_path}'";
					unlink($realpath.$_POST['ypic']);
				}
				if(isset($_FILES['address']) && $_FILES['address']['size']!=0){//更换video
					$pic_path=GetPic("address",$realpath,"1");
					$sql.=",yjl_address='{$pic_path}'";
					unlink($realpath.$_POST['yvideo']);
				}
				$sql.=" where yjl_vid='{$_POST['vid']}'";
				//echo $sql;
					mysql_query($sql,$conn);
				$num=mysql_affected_rows($conn);
				//echo $num;
				$url="";
				if($num<1){
					echo "<script>alert('修改失败！');</script>";
					$url="doUpdateVideo.php";
				}else{
					echo "<script>alert('修改成功！');</script>";
					$url="control_video.php";
				}
				echo "<meta http-equiv='Refresh' content='0;URL={$url}'>"; //跳转界面
			}
		   $sql="select * from fishvideo_video where yjl_vid={$_GET['id']}";
		   $result=mysql_query($sql,$conn);
		   $row=mysql_fetch_array($result);
		?>
	<div id="content">
		<br>
		<form role="form"  method="post" action='doUpdateVideo.php' enctype="multipart/form-data">
		<form method="POST" action="doUpdateVideo.php" enctype="multipart/form-data">
			<table class="table">
				<input type='hidden' name="vid" value=<?php  echo "'{$row['yjl_vid']}'";?>>
				<input type='hidden' name="ypic" value=<?php  echo "'{$row['yjl_pic']}'";?>>
				<input type='hidden' name="yvideo" value=<?php  echo "'{$row['yjl_address']}'";?>>
				<tr><th>影片名称</th><td><input type="text" class="form-control" required="required" name="videoname"
				value=
				<?php 
					echo "'{$row['yjl_videoname']}'";
					?>></td></tr>
				<tr><th>影片类型</th>
				<td><select class="form-control" required="required" name="tid">
					<?php						
							require_once("../utils/upload.php");
							require_once("../utils/db.php");
							$conn=connect();						
							$sql="select * from fishvideo_videotype";
							$result = mysql_query($sql);
							while($rowf = mysql_fetch_array($result)){//得到每一列的结果
							echo "<option value='{$rowf['yjl_tid']}' ";
							if($rowf['yjl_tid']==$row['yjl_tid']){
								echo "selected";
							}
								echo ">{$rowf['yjl_typename']}</option>";
						}
						mysql_close($conn);
					?>
				</select></td>
				<tr><th>缩略图</th><td><img src=<?php
					echo "'{$realpath}{$row['yjl_pic']}'";
				?> width="60px" height="60px"></td></tr>
				<tr><th>上传缩略图</th><td><input type="file" class="form-control" name="pic"></td></tr>
				<tr><th>影片介绍</th><td><textarea name="intro" class="form-control" rows="3" cols="20"
				placeholder="剧情介绍。。。。。">
				<?php
					echo $row['yjl_intro'];
				?></textarea></td></tr>
				<tr><th>影片宣传介绍</th><td><input type="text" name="lintro" class="form-control" rows="3" cols="20"
				placeholder="简短引言，宣传语。。。。。" value=<?php
					echo "'{$row['yjl_lintro']}'";
				?>></td></tr>
				<tr><th>影片播放地址</th><td><a href=<?php
					echo "'{$realpath}{$row['yjl_address']}'";
				?>>点击播放</a></td></tr>
				<tr><th>上传影片</th><td><input type="file" class="form-control" name="address"></td></tr>
			</table>
				<div id="pageButton">
					<span id="right">
						<button type="submit" name="changeVideo" class="btn btn-primary" style='width:120px'>
						   修改
						</button>
					</span>
				</div>
		</form>
	 </div>
</body>
</html>